package com.twu.biblioteca;

public class User
{
    protected static User[] list=seed();
    protected static int total=list.length;

    String name,email,phone,libraryNo,password;

    User(String userLibraryNo,String userPassword,String useName,String userEmail,String userPhone)
    {
        libraryNo=userLibraryNo;
        password=userPassword;
        name=useName;
        email=userEmail;
        phone=userPhone;
    }

    protected static boolean isValidLibraryNumber(String number)
    {
        return number.matches("\\d{3}-\\d{4}");
    }

    protected static User authenticate(String enteredUser, String enteredPassword)
    {
        int i;
        for(i=0;i<total;i++)
        {
            if(list[i].libraryNo.equals(enteredUser)&&list[i].password.equals(enteredPassword))
                return list[i];
        }
        return null;
    }

    private static void displayHeader()
    {
        System.out.print("NAME\t\tEMAIL\t\t\t\t\tPhone\n\n");
    }
    protected void showMembershipDetails()
    {
        displayHeader();
        System.out.print(name+"\t"+email+"\t"+phone+"\n");

    }

    public static User[] seed()
    {
        return new User[]{new User("045-1991","qwertyuiop","Siddharth","sidguptajhs@yahoo.in","12345678"),new User("712-1991","asdfghjkl","Utkarsh","uttu.khandelwal@gmail.com","9898989899")};
    }

}
